var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("EventData"),
    i = t("Util"),
    s = t("ConfS"),
    c = t("fightManager"),
    l = t("fun"),
    u = t("enemy"),
    p = cc._decorator,
    f = p.ccclass,
    d = p.property,
    h = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (e.prefab = null), (e.enemycount = new a.default(0)), (e.maxenemycount = 0), e;
        }
        return (
            n(e, t),
            (e.prototype.clone = function () {
                return this.enemys.slice();
            }),
            (e.prototype.onEnable = function () {
                var t = this;
                if (((this.enemys = []), (this.fight = this.getComponent(c.default)), c.default.ispvp)) {
                    this.add(c.default.adata);
                    for (var e = 0; e < 7; e++) this.add(l.cloneAdata(c.default.adata));
                } else {
                    c.default.fubendata.guding.forEach(function (e) {
                        t.add(s.DatasManager.NPCDatasById[e]);
                    });
                }
            }),
            (e.prototype.add = function (t) {
                var e = cc.instantiate(this.prefab),
                    o = e.getComponent(u.default);
                c.default.ispvp ? (o.adata = t) : (o.infodata = t),
                    this.enemys.push(o),
                    this.fight.bodys.addChild(e),
                    (e.active = !0),
                    this.maxenemycount++,
                    this.enemycount.value++;
            }),
            (e.prototype.remove = function (t, e) {
                if ((void 0 === e && (e = !0), e)) {
                    var o = 0,
                        n = 0;
                    if (
                        (t.adata
                            ? ((o = t.adata.gailv), (n = t.adata.fall))
                            : ((o = t.infodata.diaoluogailv), (n = t.infodata.diaoluobao)),
                        i.isRandom(o))
                    ) {
                        var r = t.node.x - c.default.inst.camera.node.parent.x,
                            a = t.node.y - c.default.inst.camera.node.parent.y,
                            s = l.randomFall(n);
                        c.default.inst.view.add(s.cashType, s.currency, r, a);
                    }
                }
                i.removeArray(this.enemys, t),
                    this.enemycount.value--,
                    0 == this.enemycount.value && this.fight.消灭敌人胜利();
            }),
            r([d(cc.Node)], e.prototype, "prefab", void 0),
            (e = r([f], e))
        );
    })(cc.Component);
o.default = h;
